﻿using MVCOA.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MVCOA.Areas.Manage.Controllers
{
    public class ContactUsController : Controller
    {
        //
        // GET: /Manage/ContactUs/

        public ActionResult Index()
        {
            List<MODEL.ContactU> cus = OperateContext.Current.BLLSession.IContactUBLL.GetListBy(s => true).Select(s=>s.ToPOCO()).ToList();
            if(cus.Count!=0)
            {
                ViewBag.Id = cus[0].id;
                ViewBag.qq = cus[0].qq;
                ViewBag.email = cus[0].email;
                ViewBag.phone1 = cus[0].phone;
                ViewBag.phone2 = cus[0].phone2;

            }
            
            return View();
        }
        [HttpPost]
        public ActionResult Setdata()
        {
            int fid = Convert.ToInt32(Request.Form["id"]);
            string fqq = Request.Form["qq"];
            string femail = Request.Form["email"];
            string fphone1 = Request.Form["phone1"];
            string fphone2 = Request.Form["phone2"];
            MODEL.ContactU cu = new MODEL.ContactU(){id = fid,qq = fqq,email = femail,phone = fphone1,phone2 = fphone2};
            OperateContext.Current.BLLSession.IContactUBLL.Modify(cu,"qq","email","phone","phone2");
            return Redirect("Index");
        }
    }
}
